from sqlalchemy import Column,Table,CHAR,ForeignKey
from sqlalchemy.sql.expression import null
from ..data import meta

from pydantic import BaseModel
from typing import Optional
from enum import Enum

leave_school_information_table=Table(
    'leave_school_information',meta,
    Column(
        'leave_S_ID',CHAR(60),
        primary_key=True,
        nullable=False,
        unique=True,
    ),
    Column(
        'leave_S_name',CHAR(60),
        nullable=False,
    ),
    Column(
        'leave_S_bel_B_name',CHAR(60),
		ForeignKey('building.building_id'),
        nullable=False,
    ),
    Column(
        'leave_S_bel_D_number',CHAR(60),
        nullable=False,
    ),
    Column(
        'leave_kind',CHAR(60),
        nullable=False,
    ),
    Column(
        'leave_reason',CHAR(60),
        nullable=True,
    ),
    Column(
        'leave_date',CHAR(60),
        nullable=False,
    ),
    Column(
        'serve_status',CHAR(60),
        nullable=False,
    )
)


class HandleType(str,Enum):
    accept="同意"
    refused="拒绝"


class LeaveSchoolStatus(str,Enum):
    pending="待处理"
    finished="已通过"
    failed="申请失败"


class LeaveSchoolInformationInDB(BaseModel):
    leave_S_ID:str
    leave_S_name:str
    leave_S_bel_B_name:str
    leave_S_bel_D_number:str
    leave_kind:str
    leave_reason:Optional[str]
    leave_date:str
    serve_status:LeaveSchoolStatus